/**
 *
 * by littlefean
 */

window.onload = function () {

    let F = x => x;  // 输入的函数
    let A = 0;
    let B = 1;
    let derX = 1;
    let limX = 1;

    let funcInput = document.querySelector(`.funcInput`);

    // 积分区域
    let a = document.querySelector(`.a`);
    let b = document.querySelector(`.b`);
    // output
    let output = document.querySelector(`.output`);

    // 开始计算的按钮
    let start = document.querySelector(`.start`);
    start.addEventListener("click", () => {
        update();
        let res1 = integral(F, A, B);
        output.innerHTML = `计算的结果是${res1}`;

        let res2 = derivation(F, derX);
        output2.innerHTML = `左导数是${res2[0]}<br>右导数是${res2[1]}`;

        let res3 = limit(F, limX);
        output3.innerHTML = `左极限是${res3[0]}<br>右极限是${res3[1]}`;
    })

    // 根据输入的内容更新信息
    function update() {
        F = eval("x => " + replaceFuncStr(funcInput.value));
        A = +a.value;
        B = +b.value;
        derX = +derXInput.value;
        limX = +limXInput.value;
    }

    // 在某位置求导输入
    let derXInput = document.querySelector(`.derXInput`);

    // 求导结果
    let output2 = document.querySelector(`.output2`);

    // 在某位置求极限输入
    let limXInput = document.querySelector(`.limXInput`);
    let output3 = document.querySelector(`.output3`);

}
